/* Vertex shader for per-pixel color interpolation */

/* A pass-through shader that assigns the vertex color
   to a global varying 4-vector for color.  This color
   will be interpolated through every pixel in the object
   before it gets to the fragment program. */

attribute vec3 bezier_Pos;
attribute vec3 slice_Origin;

varying vec4 color_out;

void main(void)
{
	/* we still need to assign a position and color for 
 	   the vertex.  By overriding the standard GL pipeline,
 	   GL no longer does this for us by default. 
	*/

	vec4 pos;
	vec3 sliceVec;
	vec3 tmpVec;
	mat3 scaleMatr = mat3(bezier_Pos.y,0.,0.,
		0.,1.,0.,
		0.,0.,bezier_Pos.y);
						
	sliceVec = gl_Vertex.xyz - slice_Origin;
	sliceVec = normalize(sliceVec);
	tmpVec = scaleMatr*sliceVec;
	
	pos=vec4(tmpVec.x,bezier_Pos.x,tmpVec.z,gl_Vertex.w);
	gl_Position = gl_ModelViewProjectionMatrix*pos;
	color_out = gl_Color;
}
